<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.jamwiki.model.*,org.jamwiki.*,org.jamwiki.servlets.*" %> 
 
<% 
   
   String[] userRoles = request.getParameterValues("userRole");
   String candidateUser = request.getParameter("userId");
   int userId = Integer.parseInt(candidateUser);
   if(null != userRoles && userRoles.length>0){
       String[] userRoleStr = new String[userRoles.length];
       
       for(int i=0;i<userRoles.length;i++){
       StringBuffer str = new StringBuffer();
       		 str.append(userId);
             str.append("|");
             str.append("2");
             str.append("|");
             str.append(userRoles[i]);
             userRoleStr[i] = str.toString();
             System.out.println("str:" + str);
       } 
       
	   List roles = ServletUtil.buildRoleArray(userId, -1, userRoleStr); 
	   WikiBase.getDataHandler().writeRoleMapUser(userId, roles, null);
   }else{
       WikiBase.getDataHandler().deleteRoleMapUser(userId,null);
   }
%>
<script>
 alert("授权成功");
 window.close(); 
</script>